package com.xinchao.controller;

import com.xinchao.core.constant.ResponseConstant;
import com.xinchao.core.exception.CmccApiException;
import com.xinchao.core.util.CmccApiUtils;
import com.xinchao.model.sys.JsonResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *
 * @author dxy
 * @date 2018/8/15 11:01
 */
@Controller
@RequestMapping(value = "/cmcc")
public class CmccApiTestController {

	@ResponseBody
	@RequestMapping(value = "testICCID")
	public Object testICCID(String method, String iccids,  String month, String appKeyValue, String secrect, String groupCode) {
		if ( StringUtils.isBlank(method) || StringUtils.isBlank(iccids) || StringUtils.isBlank(appKeyValue)
				|| StringUtils.isBlank(secrect) || StringUtils.isBlank(groupCode)) {
			return new JsonResponse(ResponseConstant.CODE_FAIL, "输入参数不能为空");
		}
		String result = null;
		try {
			result = CmccApiUtils.queryByICCID(method, iccids, false, month, appKeyValue, secrect, groupCode);
		} catch (CmccApiException e) {
			e.printStackTrace();
		}
		System.out.println("---------------result----------: " + result);
		return result;
	}

	@ResponseBody
	@RequestMapping(value = "testIMSI")
	public Object testIMSI(String method, String imsis,  String appKeyValue, String secrect, String groupCode) {
		if ( StringUtils.isBlank(method) || StringUtils.isBlank(imsis) || StringUtils.isBlank(appKeyValue)
				|| StringUtils.isBlank(secrect) || StringUtils.isBlank(groupCode)) {
			return new JsonResponse(ResponseConstant.CODE_FAIL, "输入参数不能为空");
		}
		String result = null;
		try {
			result = CmccApiUtils.queryByIMSI(method, imsis, false, appKeyValue, secrect, groupCode);
		} catch (CmccApiException e) {
			e.printStackTrace();
		}
		System.out.println("---------------result----------: " + result);
		return result;
	}
	@ResponseBody
	@RequestMapping(value = "test")
	public Object test(String method, String iccid, String month, String appKeyValue, String secrect, String groupCode) {
		if ( StringUtils.isBlank(method) || StringUtils.isBlank(iccid) || StringUtils.isBlank(appKeyValue)
				|| StringUtils.isBlank(secrect) || StringUtils.isBlank(groupCode)) {
			return new JsonResponse(ResponseConstant.CODE_FAIL, "输入参数不能为空");
		}
		String result = null;
		try {
			result = CmccApiUtils.queryByICCID(method, iccid, false, month, appKeyValue, secrect, groupCode);
		} catch (CmccApiException e) {
			e.printStackTrace();
		}
		System.out.println("---------------result----------: " + result);
		return result;
	}

}
